package com.runrun.com.runrun.sqlsession;

import com.runrun.config.XMLConfigBuilder;
import com.runrun.io.resources;
import com.runrun.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionFactoryBuilder {
    // todo 依旧差点没转换过来思路，目前写的是框架层次的东西，不会将路径写死在框架中，应该是将流传入到该方法中
    public SqlSessionFactory build(InputStream inputStream) throws PropertyVetoException, DocumentException {
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        //获取到了configuration中所存的信息，下一步就是
        Configuration configuration = xmlConfigBuilder.parseConfig(inputStream);
        DefaultSqlSessionFactory defaultSqlSessionFactory = new DefaultSqlSessionFactory(configuration);
        return defaultSqlSessionFactory;
    }
}
